package FlowGram.Application.Parser.Actions.Control;

import FlowGram.Application.Parser.FinchParser;
import FlowGram.Application.Parser.FinchProgramFlow;
import FlowGram.Application.Parser.Actions.FinchAction;
import FlowGram.Application.Parser.Controllers.FinchController;


/**
 * 
 * @author thackray
 *
 */
public abstract class ControlAction extends FinchAction {

	
	protected FinchParser parser;
	protected FinchProgramFlow innerFlow;

	public ControlAction(FinchParser parser){
		this.parser = parser;
	}
	public ControlAction(){
		this.innerFlow = new FinchProgramFlow();
	}
	public void setInnerFlow(FinchProgramFlow pf){
		this.innerFlow = pf;
	}
	public FinchProgramFlow getInnerFlow(){
		return this.innerFlow;
	}
	public abstract String toCode(int indent);
	public String toCode(){
		return this.toCode(0);
	}
	
	public void ensureController(FinchController controller){
		this.ensureController(controller, this.innerFlow);
	}
	public void ensureController(FinchController controller, FinchProgramFlow flow){
		if(flow != null && !flow.hasController(controller.getName())){
			flow.addController(controller);
		}
	}
}
